package com.andnnl.json;

import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONUtil;

import java.util.HashMap;

/**
 * Created by chenss on 2021/11/19.
 */
public class JsonToMapTest {
    public static void main(String[] args) {
        String json="{\n" +
                "    \"01\": {\n" +
                "        \"content\": \"请 输入 内容\",\n" +
                "        \"label\": \"2\",\n" +
                "        \"label_desc\": \"行业\",\n" +
                "        \"score\": 1.0000098943710327\n" +
                "    },\n" +
                "    \"02\": {\n" +
                "        \"content\": \"请 输入 内容\",\n" +
                "        \"label\": \"2\",\n" +
                "        \"label_desc\": \"行业\",\n" +
                "        \"score\": 1.0000098943710327\n" +
                "    }\n" +
                "}";
        HashMap map = JSONUtil.toBean(json, HashMap.class);
        System.out.println(map);
        HashMap obj = MapUtil.get(map, "01",HashMap.class);
        System.out.println(obj);
        HashMap obj3 = MapUtil.get(map, "03",HashMap.class);
        System.out.println(obj3);

        String label=MapUtil.getQuietly(MapUtil.get(map, "01",HashMap.class), "label",String.class,"");
        System.out.println(label);
    }
}
